<?php
/**
 * UEmail.php
 * 
 * @author mw
 *
 */
/**
 * UEmail
 * 
 * @author mw
 * @package Utility
 *
 */
class UEmail extends UUtility {
	/**
	 * Costruttore
	 */
	function __construct(){
		parent::__construct();
	}
	/**
	 * invia_email
	 * 
	 * @param string $from
	 * @param string $to
	 * @param string $name
	 * @param string $subject
	 * @param string $body
	 */
	public function invia_email($from,$to,$name,$subject,$body){
		$a = $name.' <'.$to.'>';
		$headers = 'From: Admin <'.$from.">\r\n";
		return mail($a,$subject,$body,$headers);
	}
	/**
	 * invia_mass_mail
	 * @param string $form
	 * @param string $to
	 * @param string $addresses
	 * @param string $subject
	 * @param string $body
	 */
	public function invia_mass_mail($from,$to,$addresses,$subject,$body){
		$headers = 'From: Admin <'.$from.">\r\n";
		$headers .= "BCC:";
		
		$i = 0;
		
		foreach($addresses as $a){
			if($i == 0){
				$i++;
				$headers .= $a;
			}else{
				$headers .= ','.$a;
			}
		}
		
		$headers .= "\r\n";
		
		return mail($to,$subject,$body,$headers);
		
	}
	
}